package bairui.international.model.domain.jpa;

/**
 *
 * @see TB_UserInfo 用户信息
 *
 */
public class TestData_TB_UserInfo
{

	private final static org.apache.commons.text.RandomStringGenerator Generator = new org.apache.commons.text.RandomStringGenerator.Builder().withinRange(new char[][]{{'a','z'}, {'A','Z'}, {'0','9'}}).build();

	@SuppressWarnings({ "unchecked", "rawtypes" })
	@org.springframework.transaction.annotation.Transactional(rollbackFor=java.lang.Throwable.class)
	public static TB_UserInfo saveMust(
		org.springframework.context.ApplicationContext context,
		bairui.international.model.domain.jpa.TB_ProductOrder productOrder
	){
		org.springframework.data.jpa.repository.JpaRepository repository = (org.springframework.data.jpa.repository.JpaRepository)context.getBean("repository_UserInfo");
		return (TB_UserInfo)repository.save(newMust(
				productOrder
			));
	}
	
	public static TB_UserInfo newMust(
		bairui.international.model.domain.jpa.TB_ProductOrder productOrder
	){
		return new TB_UserInfo(new TB_UserInfo.MustProperties() {
			/** 产品订单 */
			@Override public bairui.international.model.domain.jpa.TB_ProductOrder getProductOrder(){
				return productOrder;
			}
		});
	}
	

	@SuppressWarnings({ "unchecked", "rawtypes" })
	@org.springframework.transaction.annotation.Transactional(rollbackFor=java.lang.Throwable.class)
	public static TB_UserInfo saveAll(
		org.springframework.context.ApplicationContext context,
		bairui.international.model.domain.jpa.TB_ProductOrder productOrder
	){
		org.springframework.data.jpa.repository.JpaRepository repository = (org.springframework.data.jpa.repository.JpaRepository)context.getBean("repository_UserInfo");
		return (TB_UserInfo)repository.save(newAll(
				productOrder
			));
	}
	
	public static TB_UserInfo newAll(
		bairui.international.model.domain.jpa.TB_ProductOrder productOrder
	){
		return new TB_UserInfo(
			new TB_UserInfo.MustProperties() {
				/** 产品订单 */
				@Override public bairui.international.model.domain.jpa.TB_ProductOrder getProductOrder(){
					return productOrder;
				}
			},
			new TB_UserInfo.OptionalSingleProperties() {
				/** 微信昵称 */
				@Override public String getNickName(){
					return Generator.generate(0, 255);
				}
				/** 真实姓名 */
				@Override public String getRealName(){
					return Generator.generate(0, 30);
				}
				/** 公司 */
				@Override public String getCompany(){
					return Generator.generate(0, 255);
				}
				/** 用户类型 */
				@Override public bairui.international.model.type.Type_User getUserType(){
					return bairui.international.model.type.Type_User.General;
				}
			}
		);
	}
	

}
